home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994…tember: Reference Library / Dev.CD Sep 94.toast / Technical Documentation / C.S.M.P. Digests / csmp-digest-v3-044 / doubleCR.1 < prev   
Encoding:
Text File  |  1994-07-12  |  53.6 KB  |  1,398 lines

  1. C.S.M.P. Digest             Tue, 12 Jul 94       Volume 3 : Issue 44
  2.  
  3. Today's Topics:
  4.  
  5.         "Power Mac Programming Starter Kit", by Tom Thompson
  6.         AppleTalk Prefered vs. Alternate Interface?
  7.         CodeWarrior inline problem
  8.         Mac Pathname Syntax
  9.         MacTCP Berkeley socket wrapper?
  10.         MacsBug-How Do I...
  11.         Receiving Events in AppleScript
  12.         [Q] ReleaseResource, PICTs and handles
  13.         computer strategy
  14.  
  15.  
  16.  
  17. The Comp.Sys.Mac.Programmer Digest is moderated by Francois Pottier
  18. (pottier@clipper.ens.fr).
  19.  
  20. The digest is a collection of article threads from the internet newsgroup
  21. comp.sys.mac.programmer.  It is designed for people who read c.s.m.p. semi-
  22. regularly and want an archive of the discussions.  If you don't know what a
  23. newsgroup is, you probably don't have access to it.  Ask your systems
  24. administrator(s) for details.  If you don't have access to news, you may
  25. still be able to post messages to the group by using a mail server like
  26. anon.penet.fi (mail help@anon.penet.fi for more information).
  27.  
  28. Each issue of the digest contains one or more sets of articles (called
  29. threads), with each set corresponding to a 'discussion' of a particular
  30. subject.  The articles are not edited; all articles included in this digest
  31. are in their original posted form (as received by our news server at
  32. nef.ens.fr).  Article threads are not added to the digest until the last
  33. article added to the thread is at least two weeks old (this is to ensure that
  34. the thread is dead before adding it to the digest).  Article threads that
  35. consist of only one message are generally not included in the digest.
  36.  
  37. The digest is officially distributed by two means, by email and ftp.
  38.  
  39. If you want to receive the digest by mail, send email to listserv@ens.fr
  40. with no subject and one of the following commands as body:
  41.     help                        Sends you a summary of commands
  42.     subscribe csmp-digest Your Name    Adds you to the mailing list
  43.     signoff csmp-digest            Removes you from the list
  44. Once you have subscribed, you will automatically receive each new
  45. issue as it is created.
  46.  
  47. The official ftp info is //ftp.dartmouth.edu/pub/csmp-digest.
  48. Questions related to the ftp site should be directed to
  49. scott.silver@dartmouth.edu. Currently no previous volumes of the CSMP
  50. digest are available there.
  51.  
  52. Also, the digests are available to WAIS users.  To search back issues
  53. with WAIS, use comp.sys.mac.programmer.src. With Mosaic, use
  54. http://www.wais.com/wais-dbs/comp.sys.mac.programmer.html.
  55.  
  56.  
  57. -------------------------------------------------------
  58.  
  59. >From nagle@netcom.com (John Nagle)
  60. Subject: "Power Mac Programming Starter Kit", by Tom Thompson
  61. Date: Tue, 28 Jun 1994 00:14:57 GMT
  62. Organization: NETCOM On-line Communication Services (408 261-4700 guest)
  63.  
  64.     Just bought "Power Macintosh Programming Starter Kit", by Tom
  65. Thompson (ISBN 1-56830-091-3).  This is a cute little book, but
  66. it's not quite what the title indicates.  You get a 418-page book,
  67. and a CD-ROM with a very limited version of the MetroWerks compilers.
  68. (You can't do anything but work with the sample code on the CD-ROM.)
  69.  
  70.     This book has attitude.  It's not one of those "The Mac is easy"
  71. books; it's a macho programming book by an old-time low-level Mac hacker.
  72. The first real sample application isn't something like a draw program; 
  73. it's a program to eject the currently mounted CD while file sharing is active.  
  74. The second sample application is an INIT which changes the screen depth when 
  75. some funny character combination is hit. There's
  76. trap patching, mixed 68K/PPC code, accessing of low-memory globals, 
  77. and 68K code that manipulates the stack pointer.  All the resources are
  78. written in Rez, by hand.  There's even some inline assembly 68K assembly
  79. code written in hex.  No PPC machine code, though.
  80.  
  81.      The approach taken is strictly C.  No new-fangled object-oriented
  82. programming here.  None of that exotic class library stuff.  You do things
  83. by calling the Toolbox, like Bill Atkinson intended.
  84.  
  85.      But if you want a readable explaination of how to do fat trap patches,
  86. this is the book for you.  
  87.  
  88.                     John Nagle
  89.  
  90. ---------------------------
  91.  
  92. >From npearl@magnus.acs.ohio-state.edu (Nathan Y Pearlstein)
  93. Subject: AppleTalk Prefered vs. Alternate Interface?
  94. Date: 27 Jun 1994 17:57:01 GMT
  95. Organization: The Ohio State University
  96.  
  97. Hi, According to THINK Reference there are 2 ways of using AppleTalk,
  98. the prefered or the alternate interface.  If I use the alternate
  99. interface I don't have to write a socket listener, but if I use the
  100. prefered method I do.  What would be the drawbacks of using the
  101. alternate interface?  Please don't send guesses.
  102. Thanks
  103.  
  104. -- 
  105. DarkNater - pearlstein.1@osu.edu
  106.  
  107. +++++++++++++++++++++++++++
  108.  
  109. >From npearl@magnus.acs.ohio-state.edu (Nathan Y Pearlstein)
  110. Date: 27 Jun 1994 18:03:42 GMT
  111. Organization: The Ohio State University
  112.  
  113. In article <2un3td$83d@charm.magnus.acs.ohio-state.edu>,
  114. Nathan Y Pearlstein <npearl@magnus.acs.ohio-state.edu> wrote:
  115. >Hi, According to THINK Reference there are 2 ways of using AppleTalk,
  116. >the prefered or the alternate interface.  If I use the alternate
  117. >interface I don't have to write a socket listener, but if I use the
  118. >prefered method I do.  What would be the drawbacks of using the
  119. >alternate interface?  Please don't send guesses.
  120. >Thanks
  121.  
  122. Silly me, I should also mention that I have to use DDP.
  123.  
  124.  
  125. -- 
  126. DarkNater - pearlstein.1@osu.edu
  127.  
  128. +++++++++++++++++++++++++++
  129.  
  130. >From jumplong@aol.com (Jump Long)
  131. Date: 28 Jun 1994 03:28:05 -0400
  132. Organization: America Online, Inc. (1-800-827-6364)
  133.  
  134. In article <2un3td$83d@charm.magnus.acs.ohio-state.edu>,
  135. npearl@magnus.acs.ohio-state.edu (Nathan Y Pearlstein) writes:
  136.  
  137. >Hi, According to THINK Reference there are 2 ways of
  138. >using AppleTalk, the prefered or the alternate interface.
  139. >If I use the alternate interface I don't have to write
  140. >a socket listener, but if I use the prefered method I do.
  141. >What would be the drawbacks of using the alternate
  142. >interface?  Please don't send guesses.
  143.  
  144. Drawbacks...
  145. 1) Apple has dropped all support of the alternate interface.
  146. 2) It has bugs that'll never be fixed.
  147. 3) I have already written a socket listener that does everything the
  148. one supplied with the alternate interface does, plus mine buffers
  149. packets. It is in the Tech Note "AppleTalk, the Rest of the Story"
  150. and in the sample "Network Watch (DMZ)"
  151. 4) The alternate interface uses network events which aren't supported
  152. any longer.
  153.  
  154. Is that enough?
  155.  
  156. - Jim Luther
  157.  
  158.  
  159. ---------------------------
  160.  
  161. >From philip@cs.wits.ac.za (Philip Machanick)
  162. Subject: CodeWarrior inline problem
  163. Date: 26 Jun 1994 16:58:49 GMT
  164. Organization: Computer Science Dept, U of Witwatersrand
  165.  
  166. Even though a member function is declared incline in the class, if I have a
  167. call 
  168. to it before its code actually appears, the compiler complains "illegal
  169. inline function" when it sees the code with inline in front of it.
  170.  
  171. Moving the code to before the call makes the compiler happy.
  172.  
  173. In my opinion this is a bug since other C++ compilers can deal with this
  174. with no problem.
  175.  
  176. The workaround of moving the inline function to before it's called is no
  177. big problem (I can't imagine anyone wanting mutually recursive inlines -
  178. what would they expand to?). But it's irritating because it means I can't
  179. keep my source file in the order I want it.
  180. -- 
  181. Philip Machanick                   philip@cs.wits.ac.za
  182. Department of Computer Science, University of the Witwatersrand
  183. 2050 Wits, South Africa
  184. phone 27(11)716-3309  fax 27(11)339-7965
  185.  
  186. +++++++++++++++++++++++++++
  187.  
  188. >From "Andrew C. Plotkin" <ap1i+@andrew.cmu.edu>
  189. Date: Sun, 26 Jun 1994 13:53:10 -0400
  190. Organization: Information Technology Center, Carnegie Mellon, Pittsburgh, PA
  191.  
  192. Excerpts from netnews.comp.sys.mac.programmer: 26-Jun-94 CodeWarrior
  193. inline problem Philip Machanick@cs.wits (828)
  194.  
  195. > Even though a member function is declared inline in the class, if I have a
  196. > call 
  197. > to it before its code actually appears, the compiler complains "illegal
  198. > inline function" when it sees the code with inline in front of it.
  199.  
  200. > Moving the code to before the call makes the compiler happy.
  201.  
  202. > In my opinion this is a bug since other C++ compilers can deal with this
  203. > with no problem.
  204.  
  205. It's very likely that the other C++ compilers are dealing with it by
  206. ignoring the "inline" -- that is, they generate a normal member function
  207. which is called with the usual calling mechanism. This is easier than
  208. going through the rest of the compilation to find the inline definition,
  209. and then going back to compile the function that calls the inline
  210. function.
  211.  
  212. I'm not certain that they're doing it this way, but you might want to
  213. create a test case and examine the assembly code to see. It's something
  214. to consider; it's possible for a C++ programmer to get silently horked
  215. by this, where the compiler isn't giving him the inlining optimizations
  216. that he wants.
  217.  
  218. If CodeWarrior isn't willing to do that, it's a problem (what you're
  219. doing is legal C++, I believe) but it does point out the silent problem
  220. you would have with some other compilers.
  221.  
  222. --Z
  223.  
  224. "And Aholibamah bare Jeush, and Jaalam, and Korah: these were the borogoves..."
  225.  
  226. +++++++++++++++++++++++++++
  227.  
  228. >From johnmce@world.std.com (John McEnerney)
  229. Date: Sun, 26 Jun 1994 23:36:29 GMT
  230. Organization: The World Public Access UNIX, Brookline, MA
  231.  
  232. philip@cs.wits.ac.za (Philip Machanick) writes:
  233.  
  234. >Even though a member function is declared incline in the class, if I have a
  235. >call to it before its code actually appears, the compiler complains "illegal
  236. >inline function" when it sees the code with inline in front of it.
  237. >Moving the code to before the call makes the compiler happy.
  238.  
  239. >In my opinion this is a bug since other C++ compilers can deal with this
  240. >with no problem.
  241.  
  242. This is a hazy area. See ARM p. 104 for some examples. It is an error to 
  243. define a member function as 'inline' after it has already been called. It 
  244. is not clear from the notes whether it is legal if the function was 
  245. declared 'inline' (but not defined) in the class. I'd say it is probably 
  246. legal, and we are being too strict; I'll pass it on to the C++ front-end 
  247. architect.
  248.  
  249. -- John McEnerney, Metrowerks PowerPC Product Architect
  250.  
  251. +++++++++++++++++++++++++++
  252.  
  253. >From philip@cs.wits.ac.za (Philip Machanick)
  254. Date: 27 Jun 1994 13:32:23 GMT
  255. Organization: Computer Science Dept, U of Witwatersrand
  256.  
  257. In article <Cs12wu.Cyn@world.std.com>, johnmce@world.std.com (John
  258. McEnerney) wrote:
  259.  
  260. > philip@cs.wits.ac.za (Philip Machanick) writes:
  261. > >Even though a member function is declared incline in the class, if I have a
  262. > >call to it before its code actually appears, the compiler complains "illegal
  263. > >inline function" when it sees the code with inline in front of it.
  264. > >Moving the code to before the call makes the compiler happy.
  265. > >In my opinion this is a bug since other C++ compilers can deal with this
  266. > >with no problem.
  267. > This is a hazy area. See ARM p. 104 for some examples. It is an error to 
  268. > define a member function as 'inline' after it has already been called. It 
  269. > is not clear from the notes whether it is legal if the function was 
  270. > declared 'inline' (but not defined) in the class. I'd say it is probably 
  271. > legal, and we are being too strict; I'll pass it on to the C++ front-end 
  272. > architect.
  273.  
  274. You're right - it is hazy. However I don't think an error should be
  275. reported. In commentary on p 102, see the list of reasons an ordinary call
  276. may be generated for an inline function:
  277.   - An inline function was invoked in a program before it was defined
  278.  
  279. In a case like this the compiler has the option of either backpatching the
  280. inline in if a call is seen before the function definition, or generating
  281. code for a non-inline version of the function. My version of cfront on UNIX
  282. does the latter, and switches to using inlining after it's seen the
  283. definition of the inline function.
  284.  
  285. The key here is that the "inline" can be ignored (p 99). This is what a
  286. compiler should do if it sees "inline" then can't honour it - for whatever
  287. reason.
  288. -- 
  289. Philip Machanick                   philip@cs.wits.ac.za
  290. Department of Computer Science, University of the Witwatersrand
  291. 2050 Wits, South Africa
  292. phone 27(11)716-3309  fax 27(11)339-7965
  293.  
  294. ---------------------------
  295.  
  296. >From russell.m.brill@ccmail.jpl.nasa.gov (Russ Brill)
  297. Subject: Mac Pathname Syntax
  298. Date: 24 Jun 1994 14:14:27 GMT
  299. Organization: JPL
  300.  
  301. I've written a portable program which uses IOstreams and no toolbox calls. 
  302. What
  303. syntax is allowable for Mac pathnames?  I have discovered that the
  304. following work:
  305.  
  306.     filename                        (same folder)
  307.     :folder1:folder2...:filename    (starting at same folder)
  308.     :::folder1...:filename          (up 3 folders)
  309.     disc:folder1...:filename        (absolute path)
  310.  
  311. and I've discovered that there can't be any spaces in the pathname.  Are
  312. there any other syntaxes or restrictions.  In particular, is there a way to
  313. refer to the desktop?
  314.  
  315. +++++++++++++++++++++++++++
  316.  
  317. >From rmah@panix.com (Robert S. Mah)
  318. Date: Fri, 24 Jun 1994 11:02:39 -0500
  319. Organization: One Step Beyond
  320.  
  321. russell.m.brill@ccmail.jpl.nasa.gov (Russ Brill) wrote:
  322.  
  323. > I've written a portable program which uses IOstreams and no toolbox
  324. > calls.  What syntax is allowable for Mac pathnames?  I have discovered
  325. > that the following work:
  326. >     filename                        (same folder)
  327. >     :folder1:folder2...:filename    (starting at same folder)
  328. >     :::folder1...:filename          (up 3 folders)
  329. >     disc:folder1...:filename        (absolute path)
  330. > and I've discovered that there can't be any spaces in the pathname. 
  331. > Are there any other syntaxes or restrictions.  In particular, is
  332. > there a way to refer to the desktop?
  333.  
  334. No spaces?  Spaces never bothered my pathnames before -- what compiler
  335. and/or ANSI library are you using?
  336.  
  337. Anyway, to refer to the desktop, use something like...
  338.  
  339.   "disk:Desktop Folder:file"
  340.  
  341. The desktop displays the union of all Desktop Folder's on all mounted
  342. volumes.  The trash folder is similar in nature.
  343.  
  344. Cheers,
  345. Rob
  346. ___________________________________________________________________________
  347. Robert S. Mah  -=-  One Step Beyond  -=-  212-947-6507  -=-  rmah@panix.com
  348.  
  349. +++++++++++++++++++++++++++
  350.  
  351. >From oster@netcom.com (David Phillip Oster)
  352. Date: Fri, 24 Jun 1994 21:01:47 GMT
  353. Organization: Netcom Online Communications Services (408-241-9760 login: guest)
  354.  
  355. In article <russell.m.brill-240694070926@mac8.jpl.nasa.gov> russell.m.brill@ccmail.jpl.nasa.gov (Russ Brill) writes:
  356.  
  357. If your program does not allow spaces in pathnames, your program is wrong.
  358.  
  359. If your program does not allow the user to name all his hard disks and
  360. floppies "untitled" and still allow the user to specify which file on which
  361. hard disk she meant, then your program is wrong. (This is what the standard
  362. file dialog, and also Macintosh Drag & Drop are for.)
  363.  
  364. The desktop is represented by an invisible folder with a name something like
  365. "Desktop", in the English Language version of System 7 and later.
  366.  
  367. In systems earlier than 7, it was a bit in the FinderFlags portion of the
  368. directory entry.  In languages other than English, it may not be called
  369. "Desktop", you need to call FindFolder() to get the dirID, which is a long,
  370. and the volRef, which is a short for the desktop folder.
  371.  
  372.  
  373.  
  374. +++++++++++++++++++++++++++
  375.  
  376. >From Rick_Holzgrafe@taligent.com (Rick Holzgrafe)
  377. Date: Fri, 24 Jun 1994 20:33:33 GMT
  378. Organization: Semicolon Software
  379.  
  380. In article <russell.m.brill-240694070926@mac8.jpl.nasa.gov>,
  381. russell.m.brill@ccmail.jpl.nasa.gov (Russ Brill) wrote:
  382.  
  383. > I've written a portable program which uses IOstreams and no toolbox calls. 
  384. > What
  385. > syntax is allowable for Mac pathnames?  I have discovered that the
  386. > following work:
  387. >     filename                        (same folder)
  388. >     :folder1:folder2...:filename    (starting at same folder)
  389. >     :::folder1...:filename          (up 3 folders)
  390. >     disc:folder1...:filename        (absolute path)
  391. > and I've discovered that there can't be any spaces in the pathname.  Are
  392. > there any other syntaxes or restrictions.  In particular, is there a way to
  393. > refer to the desktop?
  394.  
  395. Spaces should not be a problem. In general any character is allowable
  396. except for colons, which are used only as separators. The Mac itself uses
  397. Pascal strings and probably wouldn't be bothered even by a null byte, but
  398. if you are working in C or C++ you may not be able to cope with null bytes
  399. because they'll be interpreted as end-of-string markers.
  400.  
  401. -- Rick Holzgrafe, a member of the Taligentsia
  402.    Rick_Holzgrafe@taligent.com
  403.    rmh@taligent.com
  404.  
  405. +++++++++++++++++++++++++++
  406.  
  407. >From nagle@netcom.com (John Nagle)
  408. Date: Sat, 25 Jun 1994 17:44:48 GMT
  409. Organization: NETCOM On-line Communication Services (408 261-4700 guest)
  410.  
  411. Rick_Holzgrafe@taligent.com (Rick Holzgrafe) writes:
  412. >Spaces should not be a problem. In general any character is allowable
  413. >except for colons, which are used only as separators. The Mac itself uses
  414. >Pascal strings and probably wouldn't be bothered even by a null byte, but
  415. >if you are working in C or C++ you may not be able to cope with null bytes
  416. >because they'll be interpreted as end-of-string markers.
  417.  
  418.      But be aware that under A/UX, the "/" is used as a separator, following
  419. UNIX conventions, and this can reach your program.  And under MPW,
  420. "/" is used to indicate regular expression expansion.  
  421.  
  422.                     John Nagle
  423.  
  424. +++++++++++++++++++++++++++
  425.  
  426. >From jumplong@aol.com (Jump Long)
  427. Date: 25 Jun 1994 17:15:02 -0400
  428. Organization: America Online, Inc. (1-800-827-6364)
  429.  
  430. In article <russell.m.brill-240694070926@mac8.jpl.nasa.gov>,
  431. russell.m.brill@ccmail.jpl.nasa.gov (Russ Brill) writes:
  432.  
  433. >What syntax is allowable for Mac pathnames?
  434.  
  435. In Inside Macintosh: Files pages 2-23 through 2-32, you'll find a
  436. section "Identifying Files, Directories, and Volumes" that includes
  437. the naming rules for pathnames.  The only omission I know of in this
  438. section of Inside Macintosh: Files is that consecutive colon (:)
  439. separator characters ascend a level in the catalog tree (for example,
  440. the pathname 'HD:System Folder:Extensions::' refers to the System
  441. Folder).  Using partial pathnames is discouraged because if a user
  442. moves things around, they break.  Using full pathnames is discouraged
  443. for the same reason as partial pathnames and for another good reason
  444. - the Macintosh allows multiple volumes to be mounted with the same
  445. volume name. If you have multiple volumes mounted with the same
  446. volume name and use a full pathname, the file system uses the first
  447. volume with a matching name that it finds by searching the VCB queue
  448. and that might not be the volume you wanted.
  449.  
  450. - Jim Luther
  451.  
  452.  
  453. +++++++++++++++++++++++++++
  454.  
  455. >From misc173@csc.canterbury.ac.nz
  456. Date: 28 Jun 94 14:24:13 +1200
  457. Organization: University of Canterbury, Christchurch, New Zealand
  458.  
  459. > for the same reason as partial pathnames and for another good reason
  460. > - the Macintosh allows multiple volumes to be mounted with the same
  461. > volume name. If you have multiple volumes mounted with the same
  462. > volume name and use a full pathname, the file system uses the first
  463. > volume with a matching name that it finds by searching the VCB queue
  464. > and that might not be the volume you wanted.
  465.     I'm writing a program somewhat like Xtree gold  on the IBM, where you
  466. get a tree view of the files, without having to worry about windows. At the
  467. moment it works by using full path names. I'm using the list manager and
  468. simply steeping back up the tree to work out the path. What alternatives are
  469. there to full path names, I know a bit about directory numbers and volume
  470. numbers, cant you just specify a volume number and a partial ( no volume name )
  471. or full path.
  472.     I really dont want to have to rewrite the list manager to include file
  473. numbers.
  474.  
  475. Thanks,
  476. Jon. 
  477.  
  478. +++++++++++++++++++++++++++
  479.  
  480. >From Jens Alfke <jens_alfke@powertalk.apple.com>
  481. Date: Tue, 28 Jun 1994 21:25:19 GMT
  482. Organization: Apple Computer
  483.  
  484. misc173@csc.canterbury.ac.nz writes:
  485. >     I'm writing a program somewhat like Xtree gold  on the IBM, where you
  486. > get a tree view of the files, without having to worry about windows.
  487.  
  488. Hmm, is this really any better than the list view in the Finder, in which you
  489. can open subfolders in an outline?
  490.  
  491. > At the
  492. > moment it works by using full path names. I'm using the list manager and
  493. > simply steeping back up the tree to work out the path. What alternatives are
  494. > there to full path names, I know a bit about directory numbers and volume
  495. > numbers
  496.  
  497. The preferred way to deal with files is by volume refNum, directory ID and
  498. filename. The volume refNum is not persistent across volume mounts but the
  499. other two are. There is a structure called an FSSpec that encapsulates this
  500. info. Most of the file manager functions that deal with files have versions
  501. that take FSSpecs.
  502.   You probably really want to get the "MoreFiles" sample code, which has all
  503. kinds of routines for dealing with files and directories, such as enumerating
  504. through all the files in a directory. Also be sure to read Inside Macintosh:
  505. Files.
  506.  
  507. >     I really dont want to have to rewrite the list manager to include file
  508. > numbers.
  509.  
  510. Huh? Don't tell me you're just displaying a textual list of pathnames. Ewwwww!
  511.  
  512. --Jens Alfke
  513.   jens_alfke@powertalk              Rebel girl, rebel girl,
  514.             .apple.com              Rebel girl you are the queen of my world
  515.  
  516. ---------------------------
  517.  
  518. >From ankh@leland.Stanford.EDU (graham hesselroth)
  519. Subject: MacTCP Berkeley socket wrapper?
  520. Date: 23 Jun 1994 17:48:39 GMT
  521. Organization: Stanford University, CA 94305, USA
  522.  
  523.     Hello,
  524.  
  525.         I was looking for some library of C or C++ code that
  526. acted as a simplified interface to the MacTCP calls, preferably
  527. compliant with the Berkeley sockets API.  Does any such beast exist,
  528. or anyother package that provides socket like calls on the Mac
  529. (socket, bind, connect, recvrfrom, sendto, etc)?
  530. Pls send replies to ankh@leland.stanford.edu 
  531.     Thanks
  532.         Graham
  533.  
  534.  
  535. +++++++++++++++++++++++++++
  536.  
  537. >From rypma@waterloo.hp.com (Ted Rypma)
  538. Date: 23 Jun 1994 20:53:01 GMT
  539. Organization: H-P Panacom Div, Waterloo, ON Canada
  540.  
  541. graham hesselroth (ankh@leland.Stanford.EDU) wrote:
  542. :     Hello,
  543.  
  544. :         I was looking for some library of C or C++ code that
  545. : acted as a simplified interface to the MacTCP calls, preferably
  546. : compliant with the Berkeley sockets API.  Does any such beast exist,
  547.  
  548. >From an earlier post...
  549.  
  550. % Get sockets.hqx from explorer.dgp.utoronto.ca in /pub/macsockets.
  551. % Be warned, though, you have to build it yourself (MPW), and it is imcomplete.
  552. % For just connecting to some server, snarf data, and close, it works fine.
  553. % One of these days I'll get around to supplying Tom with a list of patches
  554. % and then someday he'll get around to supplying an updated .hqx file of
  555. % compiled libraries and headers.
  556. % enjoy!
  557. % --
  558. % !@$^&*)($#$@!@#$^&*()_+_)(*&^$#@!$^&*()_+)(*&^$#@$^&*+_(*&^$#@#^&*()&*$#@(*&
  559. % Dominic Richens  :  dominic@oeg.carleton.ca  :  Tel. (613) 820 0764
  560. % Ontario Telepresence Project,2670 Queensview Dr.,Ottawa,ON,K2B 8K1,CANADA
  561.  
  562. Ted Rypma
  563. Waterloo, Ontario
  564.  
  565. +++++++++++++++++++++++++++
  566.  
  567. >From nagel@Rdatasys.COM (Mark D. Nagel)
  568. Date: Fri, 24 Jun 1994 18:14:28 GMT
  569. Organization: Relational Data Systems, Irvine, CA
  570.  
  571. In <2ucsnd$73m@hppadbk.waterloo.hp.com> rypma@waterloo.hp.com (Ted Rypma) writes:
  572.  
  573. >graham hesselroth (ankh@leland.Stanford.EDU) wrote:
  574. >:         I was looking for some library of C or C++ code that
  575. >: acted as a simplified interface to the MacTCP calls, preferably
  576. >: compliant with the Berkeley sockets API.  Does any such beast exist,
  577.  
  578. >From an earlier post...
  579.  
  580. >% Get sockets.hqx from explorer.dgp.utoronto.ca in /pub/macsockets.
  581.  
  582. There's also GUSI (Grand Unified Socket Interface), available from
  583. nic.switch.ch in /software/mac/src/mpw_c.  Here'e the .info file:
  584.  
  585. - ----------------------------------------------------------------------------
  586.                  G U S I -- Grand Unified Socket Interface
  587.  
  588. INTRODUCTION
  589.  
  590. GUSI is an extension and partial replacement of the MPW C runtime
  591. library.  Its main objective is to provide a more or less simple and
  592. consistent interface across the following communication domains:
  593.  
  594. Files          Ordinary Macintosh files and MPW pseudo devices.
  595. Unix           Memory based communication within a single machine
  596. Appletalk      ADSP communication over a network.
  597. PPC            Local and remote connections with the System 7 PPC Toolbox
  598. Internet       TCP and UDP connections over MacTCP.
  599.  
  600. Additionally, GUSI adds some UNIX library calls dealing with files which
  601. were missing, like chdir(), getcwd(), symlink(), and readlink(), and changes
  602. a few other library calls to behave more like their UNIX counterparts.
  603.  
  604. REQUIREMENTS
  605.  
  606. To use GUSI, you need MPW C 3.2 or later. To modify it, you additionally need
  607. MPW C++ 3.2 or later and Perl. GUSI_120.doc.sit.bin provides the documentation
  608. for non-postscript printers. Documentation in Postscript format is included.
  609. - ----------------------------------------------------------------------------
  610.  
  611. There's also a port to THINK C in the info-mac archives.
  612.  
  613. -- 
  614. Mark D. Nagel <mark.nagel@rdatasys.com>      Relational Data Systems
  615.                                              30 Executive Park, Suite 260
  616. Eat right.  Exercise.  Die anyway.           Irvine, CA 92714
  617.                                              (714) 263-3899
  618.  
  619. +++++++++++++++++++++++++++
  620.  
  621. >From creiman@netcom.com (Charlie Reiman)
  622. Date: Sat, 25 Jun 1994 05:43:44 GMT
  623. Organization: NETCOM On-line Communication Services (408 261-4700 guest)
  624.  
  625. nagel@Rdatasys.COM (Mark D. Nagel) writes:
  626.  
  627. >In <2ucsnd$73m@hppadbk.waterloo.hp.com> rypma@waterloo.hp.com (Ted Rypma) writes:
  628.  
  629. >>graham hesselroth (ankh@leland.Stanford.EDU) wrote:
  630. >>:         I was looking for some library of C or C++ code that
  631. >>: acted as a simplified interface to the MacTCP calls, preferably
  632. >>: compliant with the Berkeley sockets API.  Does any such beast exist,
  633.  
  634. >>From an earlier post...
  635.  
  636. >>% Get sockets.hqx from explorer.dgp.utoronto.ca in /pub/macsockets.
  637.  
  638. >There's also GUSI (Grand Unified Socket Interface), available from
  639. >nic.switch.ch in /software/mac/src/mpw_c. 
  640.  
  641. My old BSD library is also still available at ftp.ncsa.uiuc.edu, in
  642. /misc/unsupported. It is, believe it or not, shipping inside NCSA 
  643. Mosaic. I assume they fixed some bugs along the way, but the Macsbugs
  644. symbols show no signifigant changes. 
  645.  
  646. My code, being hammered by hundreds (thousands?) of thousands of
  647. users every day, and do I get any credit? No. Of course not. 
  648.  
  649. What? Me bitter? Nah. It comes with the territory of working as an
  650. undergrad. 
  651.  
  652. Sorry. I'll pack up my spite and regret and move along to the next
  653. newsgroup.
  654.  
  655. -- 
  656. "You can't cancel the project! We already made the T-shirts!"
  657. Charlie Reiman
  658. creiman@netcom.com
  659.  
  660. +++++++++++++++++++++++++++
  661.  
  662. >From jbrowne@zaphod.ncsa.uiuc.edu (Jim Browne)
  663. Date: 28 Jun 94 02:44:22 GMT
  664. Organization: University of Illinois at Urbana
  665.  
  666. creiman@netcom.com (Charlie Reiman) writes:
  667.  
  668. >My code, being hammered by hundreds (thousands?) of thousands of
  669. >users every day, and do I get any credit? No. Of course not. 
  670.  
  671. What did you expect, Charlie?  This is NCSA we're talking about here.
  672.  
  673. >What? Me bitter? Nah. It comes with the territory of working as an
  674. >undergrad. 
  675.  
  676. ...and the list keeps growing...
  677.  
  678. -- 
  679. Jim Browne          Random net.person for this season         jbrowne@uiuc.edu
  680.     There are more stoplights in Sunnyvale, CA. than people in my hometown.
  681.  
  682. ---------------------------
  683.  
  684. >From tpguinn@utxvms.cc.utexas.edu (Tim Guinn)
  685. Subject: MacsBug-How Do I...
  686. Date: Fri, 24 Jun 1994 01:27:47 -0600
  687. Organization: The University of Texas at Austin, Austin, Texas
  688.  
  689. As always, please forgive the uninformed newbie nature 
  690. of this post. I'm still learning.
  691.  
  692. I've gotten to where I'm pretty comfortable entering 
  693. MacsBug [by choice 8-)] and using it to <es> out of crashed 
  694. applications and save things before <rb> or <rs>.  However...  
  695. Because it's such a new experience (entering the debugger 
  696. versus a screen freeze) I've noticed I seem to be entering 
  697. it a lot.  Well, I'd like to avoid that, of course.  Most of 
  698. the time, I get Bus Error messages.
  699.  
  700. An example:  
  701.  
  702. BusError at 00036090 while reading longword from 01A50190
  703. in Supervisor data space
  704.  
  705. I understand the *what* here, I just don't understand the 
  706. *why*.  So I did this:  
  707.  
  708. dm 36090 applname
  709.  
  710. ...thinking it would tell me the name of the offender.
  711. Nope.  I got:
  712.  
  713. "0%%%%%%/% | % % P %%%"|%%"Q"%%%0%"
  714.  
  715. Uhhhhh...what is this?  Hex, right?  How do/can I see the
  716. actual Roman script (i.e., legible) name of the app/init/
  717. whatever that went out of control?  A helpful sequence of
  718. commands would be most appreciated.
  719.  
  720. What I'd like to do is either A) isolate the offender and
  721. remove it, or B) figure out how to make it get along with
  722. everything else.
  723.  
  724. Also, What do the files MrBusError and EvenBetterBusError
  725. do, actually (in newbie-ease, please)?  The ReadMes with
  726. these files indicated each would *help* with debugging, but,
  727. like their names imply (and from experience, now) I realize
  728. they actually *cause* a BusError, not prevent one.  Am I
  729. wrong?  On separate occasions I've had each in my System
  730. folder, but found they caused more problems then I'm 
  731. presently capable of handling. 
  732.  
  733. I'm thinking maybe there's just something I haven't done to
  734. configure MacsBug so it's customized to my system...
  735.  
  736. LCIII, 8/120+270, 7.1w/HSU3.0, MacsBug 6.5d6
  737.  
  738. All pointers humbly accepted with appreciation.
  739.  
  740. -tpg
  741.  
  742. ^^
  743. Tim Guinn
  744. Austin, Texas US                  ~ Sine Metu ~
  745. tpguinn@utxvms.cc.utexas.edu
  746.  
  747. +++++++++++++++++++++++++++
  748.  
  749. >From rmah@panix.com (Robert S. Mah)
  750. Date: Fri, 24 Jun 1994 03:14:55 -0500
  751. Organization: One Step Beyond
  752.  
  753. tpguinn@utxvms.cc.utexas.edu (Tim Guinn) wrote:
  754.  
  755. > BusError at 00036090 while reading longword from 01A50190 in
  756. > Supervisor data space
  757. > I understand the *what* here, I just don't understand the *why*. 
  758. > So I did this:  
  759. > dm 36090 applname
  760. > ...thinking it would tell me the name of the offender.  Nope.  I got:
  761. > "0/ |   P "|"Q"0"
  762. > Uhhhhh...what is this?  Hex, right?  How do/can I see the actual
  763. > Roman script (i.e., legible) name of the app/init/whatever that
  764. > went out of control?  A helpful sequence of commands would be most
  765.  
  766. First, the address "000360980" is the location of the _instruction_
  767. that caused the bus error, not the location of the name of the
  768. application.  The second number is the probable address (usually
  769. bogus) that the instruction was trying to access.
  770.  
  771. The current application is always displayed in the status area on the 
  772. left, just under the title "CurApName".  Alternatively, you can type
  773. CurApName to display it.  P.S. the app's name is always at 0x0910.
  774.  
  775. To find out what caused the problem, you have to be pretty knowledgable
  776. about the OS.  You can fool around with the "wh" command, which tells
  777. you memory block containing the address or the location of a trap.  If
  778. it's in the system heap, it _may_ be an extension that's causing the 
  779. problem.  Then again, maybe not...you have to examine the code to be
  780. sure.  Other useful commands include "sc" or "sc7" which do a stack 
  781. crawl so you can see the call chain.
  782.  
  783. The long and the short of it is, however, that if you don't know the
  784. internals of the code that crashed, and "es" doesn't work, then you'll
  785. probably have to reboot.
  786.  
  787.  
  788. > Also, What do the files MrBusError and EvenBetterBusError do,
  789. > actually (in newbie-ease, please)?  The ReadMes with these files
  790. > indicated each would *help* with debugging, but, like their names
  791. > imply (and from experience, now) I realize they actually *cause*
  792. > a BusError, not prevent one.  Am I wrong?  On separate occasions
  793.  
  794. No, you are right.  Both extensions are tools to aid programmers in
  795. finding bugs in their programs by intercepting or causing certain 
  796. common errors to maniftest themselves.  If you're not developing some
  797. sort of software, remove them.
  798.  
  799. Cheers,
  800. Rob
  801. ___________________________________________________________________________
  802. Robert S. Mah  -=-  One Step Beyond  -=-  212-947-6507  -=-  rmah@panix.com
  803.  
  804. +++++++++++++++++++++++++++
  805.  
  806. >From Jens Alfke <jens_alfke@powertalk.apple.com>
  807. Date: Fri, 24 Jun 1994 20:46:09 GMT
  808. Organization: Apple Computer
  809.  
  810. Okay, here's a tutorial on your friend EvenBetterBusError:
  811.  
  812. Tim Guinn, tpguinn@utxvms.cc.utexas.edu writes:
  813. > Also, What do the files MrBusError and EvenBetterBusError
  814. > do, actually (in newbie-ease, please)?  The ReadMes with
  815. > these files indicated each would *help* with debugging, but,
  816. > like their names imply (and from experience, now) I realize
  817. > they actually *cause* a BusError, not prevent one.
  818.  
  819. Yes. EBBE (which supersedes MrBE) is your friend -- it turns some types of
  820. bugs that ordinarily cause intermittent and hard-to-reproduce crashes, into
  821. guaranteed crashers. The types of bugs it catches are (a) dereferencing a
  822. NULL handle; and (b) writing to a NULL pointer. For instance:
  823.  
  824. PicHandle p = GetPicture(128);
  825. Rect r = (**p).picFrame ;
  826.  
  827. Oops, I forgot to put a PICT 128 resource in my application, so the second
  828. line is dereferencing a NULL pointer. Ordinarily location zero, which isn't
  829. used by anything on the system, contains some random garbage left over from
  830. startup. So the effect of the second line is to read eight bytes of stuff
  831. from some random location in memory. This is bad and may cause a crash later.
  832. And occasionally the garbage at location zero points to a nonexistent memory
  833. address, in which case you get a bus error.
  834.   What EBBE does is periodically (60x per second) write a particular garbage
  835. value, 0x50FF8001, into location 0. This value has the characteristic that
  836. it's not a valid memory address on any Mac configuration, so dereferencing it
  837. (by dereferencing a NULL pointer) will always cause a crash. So if you get a
  838. bus error and notice 50FF8001 (or some nearby value) in the register in
  839. question, suspect a NULL handle in your code.
  840.   Incidentally, you can often recover from a crash caused by EBBE by writing
  841. a valid address into the register that has 50FF8001 in it, and continuing.
  842. Just enter:
  843.   A0=@rombase; g
  844. but using the appropriate trashed register instead of A0.
  845.   EBBE also warns you of jumps to NULL (calling a procedure pointer whose
  846. value is NULL, or jumping into a purged code resource) since 50FF is an
  847. invalid 68000 instruction. Jumps to NULL will almost certainly kill you in
  848. any case, but with EBBE yor code stops immediately and it's easier to tell
  849. what happened.
  850.  
  851. The second thing EBBE does is, when it periodically writes the magic value
  852. into NULL, it first checks whether the value it last wrote has been changed.
  853. If so, this means somebody wrote to NULL, and it will then warn you via a
  854. DebugStr reading "Write to NIL!". Unfortunately up to one tick may have
  855. elapsed since the offending write, so it's harder to track down what's wrong,
  856. but it's still good to know. You can continue after this; it's just a warning.
  857. Here's an example of code that writes to NULL:
  858.  
  859. long *p = NewPtr(sizeof(long));
  860. *p = 0x12345678;
  861.  
  862. If you're out of memory, or your heap is hosed, NewPtr will fail and return
  863. NULL, whereupon the second line will write into location zero. One tick later
  864. EBBE will tell you about this. If you do a "dm 0" and look at the value
  865. there, it might tip you off...
  866.  
  867. --Jens Alfke
  868.   jens_alfke@powertalk              Rebel girl, rebel girl,
  869.             .apple.com              Rebel girl you are the queen of my world
  870.  
  871. +++++++++++++++++++++++++++
  872.  
  873. >From WalrathW@rferl.org (Wayne Walrath)
  874. Date: Mon, 27 Jun 1994 15:02:35 +0100
  875. Organization: RFE/RL Inc.
  876.  
  877. In article <tpguinn-240694012747@slip-4-2.ots.utexas.edu>,
  878. tpguinn@utxvms.cc.utexas.edu (Tim Guinn) wrote:
  879.  
  880. > As always, please forgive the uninformed newbie nature 
  881. > of this post. I'm still learning.
  882. > I've gotten to where I'm pretty comfortable entering 
  883. > MacsBug [by choice 8-)] and using it to <es> out of crashed 
  884. > applications and save things before <rb> or <rs>.  However...  
  885. > Because it's such a new experience (entering the debugger 
  886. > versus a screen freeze) I've noticed I seem to be entering 
  887. > it a lot.  Well, I'd like to avoid that, of course.  Most of 
  888. > the time, I get Bus Error messages.
  889.  
  890. <snip>
  891.  
  892. > All pointers humbly accepted with appreciation.
  893. > -tpg
  894. > ^^
  895. > Tim Guinn
  896. > Austin, Texas US                  ~ Sine Metu ~
  897. > tpguinn@utxvms.cc.utexas.edu
  898.  
  899. Tim,
  900.   If you are interested in understanding a little better what Macsbug is
  901. showing you, and being able to maneuver a bit better in that "underworld",
  902. pick up a copy of the book, "Debugging Mac Software with Macsbug" by Straus
  903. and Othmer $34.95 and available from APDA. It's a great reference and
  904. tutorial to have around.
  905.  
  906. -wayne
  907.  
  908. ________)|(________
  909. walrathw@rferl.org
  910.    RFE/RL Inc.
  911.  
  912. +++++++++++++++++++++++++++
  913.  
  914. >From hammel@skisas.usask.ca
  915. Date: 27 Jun 1994 16:41:27 GMT
  916. Organization: Institute of Space and Atmospheric Studies, Univ. of Sask.
  917.  
  918. In article <WalrathW-270694150235@mumcec.rferl.org> WalrathW@rferl.org (Wayne Walrath) writes:
  919. >  If you are interested in understanding a little better what Macsbug is
  920. >showing you, and being able to maneuver a bit better in that "underworld",
  921. >pick up a copy of the book, "Debugging Mac Software with Macsbug" by Straus
  922. >and Othmer $34.95 and available from APDA. 
  923.  
  924. Would anyone happen to have the ISBN number for that book?
  925.  
  926. Thanks in advance,
  927. Greg.
  928.  
  929. - ------------------------------------------------------------------------
  930. |     Greg Hammel :  HAMMEL@skisas.usask.ca or HAMMEL@sask.usask.ca      |
  931. |                                                                        |
  932. |     Disclaimer: I'm not quite sure who I speak for.                    |
  933. |                                                                        |
  934. |     "I'm a citizen of Legoland travellin Incommunicado" - Fish         |
  935. - ------------------------------------------------------------------------
  936.  
  937. +++++++++++++++++++++++++++
  938.  
  939. >From tpguinn@utxvms.cc.utexas.edu (Tim Guinn)
  940. Date: Mon, 27 Jun 1994 22:30:05 -0600
  941. Organization: The University of Texas at Austin, Austin, Texas
  942.  
  943. In article <2umvfn$pu6@tribune.usask.ca>, hammel@skisas.usask.ca wrote:
  944.  
  945. > In article <WalrathW-270694150235@mumcec.rferl.org> WalrathW@rferl.org (Wayne Walrath) writes:
  946. > >  If you are interested in understanding a little better what Macsbug is
  947. > >showing you, and being able to maneuver a bit better in that "underworld",
  948. > >pick up a copy of the book, "Debugging Mac Software with Macsbug" by Straus
  949. > >and Othmer $34.95 and available from APDA. 
  950. > Would anyone happen to have the ISBN number for that book?
  951. =======================================
  952.  
  953. 0-201-57049-1
  954.  
  955. I'm *SLOWLY* working my way through it 8-)  The only problem
  956. I have with it is that it comes with the older MacsBug.  But
  957. you can get v6.5d6 in two places I know of: 
  958.  
  959. a. develop
  960. b. ftp.apple.com (sorry, don't know the path)
  961.  
  962. -tpg
  963.  
  964. ^^
  965. Tim Guinn
  966. Austin, Texas US                  ~ Sine Metu ~
  967. tpguinn@utxvms.cc.utexas.edu
  968.  
  969. ---------------------------
  970.  
  971. >From Ricardo Marimon <rmarimon@leland.stanford.edu>
  972. Subject: Receiving Events in AppleScript
  973. Date: 28 Jun 1994 01:30:00 GMT
  974. Organization: Stanford University
  975.  
  976. Hi people,
  977.  
  978. I want to know if there is any way in which I could write a
  979. Script (using Apple's ScriptEditor) that accepts events send
  980. to it from other applications.  My particular use would be to
  981. instruct Eudora to send my Script a message whenever it
  982. receives a new message.  
  983.  
  984. I know that Eudora sends an 'eNot' event with parameters the 
  985. references to all the newly received messages.  Then my script 
  986. could do some processing on this messages, such as delete 
  987. them, or automatically reply to some of them; things easily 
  988. done using AppleScript and Eudora.
  989.  
  990. I will appreciate any help on this issue.  Thanks in advance,
  991.  
  992.  
  993. Ricardo Marimon
  994. rmarimon@leland.stanford.edu
  995.  
  996. - -
  997. I type my signature every time.  And you?  :-)
  998.  
  999. +++++++++++++++++++++++++++
  1000.  
  1001. >From Jens Alfke <jens_alfke@powertalk.apple.com>
  1002. Date: Tue, 28 Jun 1994 21:11:25 GMT
  1003. Organization: Apple Computer
  1004.  
  1005. Ricardo Marimon, rmarimon@leland.stanford.edu writes:
  1006. > I want to know if there is any way in which I could write a
  1007. > Script (using Apple's ScriptEditor) that accepts events send
  1008. > to it from other applications.
  1009.  
  1010. You add a handler for that event to the script, then save it as an app. There
  1011. are sample scripts that come with AS (on the CD at least) that illustrate
  1012. this. It gets trickier when the event is non-standard, since AS doesn't know
  1013. the terminology for the event. You probably have to use the << ... >>
  1014. notation with the raw 4-letter codes, and I can never remember where that
  1015. syntax is documented...
  1016.  
  1017. --Jens Alfke
  1018.   jens_alfke@powertalk              Rebel girl, rebel girl,
  1019.             .apple.com              Rebel girl you are the queen of my world
  1020.  
  1021. +++++++++++++++++++++++++++
  1022.  
  1023. >From hector@cs.toronto.edu (Hector Levesque)
  1024. Date: 28 Jun 94 17:19:49 GMT
  1025. Organization: U. of Toronto
  1026.  
  1027. In article <2unueo$5b4@nntp2.Stanford.EDU>, Ricardo Marimon
  1028. <rmarimon@leland.stanford.edu> wrote:
  1029. > I want to know if there is any way in which I could write a
  1030. > Script (using Apple's ScriptEditor) that accepts events send
  1031. > to it from other applications.  My particular use would be to
  1032. > instruct Eudora to send my Script a message whenever it
  1033. > receives a new message.  
  1034. > I know that Eudora sends an 'eNot' event with parameters the 
  1035. > references to all the newly received messages.  Then my script 
  1036. > could do some processing on this messages, such as delete 
  1037. > them, or automatically reply to some of them; things easily 
  1038. > done using AppleScript and Eudora.
  1039.  
  1040. Yup.  Write a script with a handler like this
  1041.  
  1042.      on <<event CSOmeNot>> msgList
  1043.         --
  1044.         -- actions to take when notified
  1045.         --
  1046.      end <<event CSOmeNot>>
  1047.  
  1048. where << means option-\ and >> means option-shift-\, then save it as a
  1049. stay-open application. Then you need to tell Eudora to send its notify
  1050. message to this application, at which time your handler will be called. 
  1051. Note that the application needs to be a stay-open application, so that if
  1052. you want to quit after you've handled the notification, you need to inlcude
  1053. a quit command. 
  1054.  
  1055. -- 
  1056. Hector Levesque
  1057. U. of Toronto
  1058. hector@cs.toronto.edu
  1059.  
  1060. ---------------------------
  1061.  
  1062. >From martino@husc10.harvard.edu (Carlo Martino)
  1063. Subject: [Q] ReleaseResource, PICTs and handles
  1064. Date: 24 Jun 94 02:37:19 GMT
  1065. Organization: Harvard University, Cambridge, Massachusetts
  1066.  
  1067. I began programming for the Mac less than a week ago, although
  1068. I have some prior familiarity with C and C++ for DOS/Windows.
  1069.  
  1070. I am using Symantec C++.  My question regards PictHandles and
  1071. generic resource handles and the relations between them.  I get
  1072. a PICT using GetPicture(int ResID).  When it comes time to 
  1073. release said PICT, ReleaseResource will not accept the PictHandle
  1074. returned by GetPicture.  This is somewhat sensible, as
  1075. ReleaseResource is defined as accepting a Handle, not a
  1076. PictHandle.  But I assume there is some way to release my PICT
  1077. resource.
  1078.  
  1079. Any help would be greatly appreciated.
  1080.  
  1081. Thank you in advance.
  1082.  
  1083. +++++++++++++++++++++++++++
  1084.  
  1085. >From jwbaxter@olympus.net (John W. Baxter)
  1086. Date: Fri, 24 Jun 1994 08:37:37 -0700
  1087. Organization: Internet for the Olympic Peninsula
  1088.  
  1089. In article <martino.772425439@husc10.harvard.edu>,
  1090. martino@husc10.harvard.edu (Carlo Martino) wrote:
  1091.  
  1092. > I began programming for the Mac less than a week ago, although
  1093. > I have some prior familiarity with C and C++ for DOS/Windows.
  1094. > I am using Symantec C++.  My question regards PictHandles and
  1095. > generic resource handles and the relations between them.  I get
  1096. > a PICT using GetPicture(int ResID).  When it comes time to 
  1097. > release said PICT, ReleaseResource will not accept the PictHandle
  1098. > returned by GetPicture.  This is somewhat sensible, as
  1099. > ReleaseResource is defined as accepting a Handle, not a
  1100. > PictHandle.  But I assume there is some way to release my PICT
  1101. > resource.
  1102.  
  1103. Cast the PicHandle to a generic Handle:
  1104.  
  1105.    ReleaseResource ((Handle)myPictureHandle);
  1106.  
  1107. Yes...casts are evil.  For things like this, they are necessary.
  1108. -- 
  1109. John Baxter    Port Ludlow, WA, USA  [West shore, Puget Sound]
  1110.    No hablo Intel.
  1111.    jwbaxter@pt.olympus.net
  1112.  
  1113. +++++++++++++++++++++++++++
  1114.  
  1115. >From Mark Hanrek <hanrek@cts.com>
  1116. Date: Sun, 26 Jun 1994 07:02:32 GMT
  1117. Organization: The Information Workshop
  1118.  
  1119. In article <martino.772425439@husc10.harvard.edu> Carlo Martino,
  1120. martino@husc10.harvard.edu writes:
  1121.  
  1122. > I am using Symantec C++.  My question regards PictHandles and
  1123. > generic resource handles and the relations between them.  I get
  1124. > a PICT using GetPicture(int ResID).  When it comes time to 
  1125. > release said PICT, ReleaseResource will not accept the PictHandle
  1126. > returned by GetPicture.  This is somewhat sensible, as
  1127. > ReleaseResource is defined as accepting a Handle, not a
  1128. > PictHandle.  But I assume there is some way to release my PICT
  1129. > resource.
  1130.  
  1131. When there is a type mismatch, it helps to think of it as simply the
  1132. signal that a human must intervene and decide what to do.
  1133.  
  1134. Unfortunately, there are no clear cut rules, otherwise, the compiler
  1135. could handle it.  The rules are ones that humans can easily deal with,
  1136. but only once we have learned what they are.
  1137.  
  1138. Chicken or the egg.
  1139.  
  1140. In order to learn, you must have working example source code handy, so
  1141. you can see what others have done.  I don't know of any reference book
  1142. that can help you with this, and when you think about it, the best
  1143. language to communicate such things is "example source code".
  1144.  
  1145. I and many others live by the approach of always keeping an eye peeled
  1146. for example source code that covers certain areas of programming that we
  1147. either need at the moment or will be needing, and downloading it when we
  1148. come across it.
  1149.  
  1150. - ---
  1151.  
  1152. There is no convenient way to declare types for things, yet also indicate
  1153. when certain types are "equivalent" in given certain situations.
  1154.  
  1155. In your case, it is 100% okay to ReleaseResource a PicHandle obtained
  1156. from GetResource.  A handle is a handle from ReleaseResource and
  1157. DisposeHandle's point of view, yet in the real programming world we also
  1158. have sub-types of handles based on what is in them, such as PicHandles.
  1159.  
  1160. Casting is a way the language allows us to temporarily change the type of
  1161. something, in a given situation, to get the COMPILER out of the fix of
  1162. not being able to understand "programming" adequately.
  1163.  
  1164.  
  1165. Hope this helps clarify things.
  1166.  
  1167. Mark Hanrek
  1168.  
  1169. P.S. Another really helpful thing to do is:  you should ALWAYS have
  1170. enabled "Check Pointer Types" and "Require Prototypes".
  1171.  
  1172. ---------------------------
  1173.  
  1174. >From jgrass@cs.umass.edu (Joshua Grass)
  1175. Subject: computer strategy
  1176. Date: 27 Jun 1994 21:34:30 GMT
  1177. Organization: University of Massachusetts, Amherst
  1178.  
  1179. I finished writing a mac game that is a pretty fun to play with two
  1180. people, but I would like to make it so that the computer can play as
  1181. well.  I'm pretty well versed in AI so I understand how hard it can
  1182. be for a computer to play any game, but I was curious if anyone had
  1183. any experience on computer strategy and possible "cheats" in the sense
  1184. of fairly simple algorithms that make the computer play (or appear to
  1185. play) a game well.  My game is cross between spaceward ho! and strategic
  1186. conquest if that helps any.  Any ideas about small memory, fairly quick
  1187. time algorithms that would help the computer would be great.  Thanks
  1188.  
  1189.                         Joshua
  1190.  
  1191.  
  1192.  
  1193. +++++++++++++++++++++++++++
  1194.  
  1195. >From rmah@panix.com (Robert S. Mah)
  1196. Date: Tue, 28 Jun 1994 00:24:34 -0500
  1197. Organization: One Step Beyond
  1198.  
  1199. jgrass@cs.umass.edu (Joshua Grass) wrote:
  1200.  
  1201. > I finished writing a mac game that is a pretty fun to play with two
  1202. > people, but I would like to make it so that the computer can play as
  1203. > well.  I'm pretty well versed in AI so I understand how hard it can
  1204. > be for a computer to play any game, but I was curious if anyone had
  1205. > any experience on computer strategy and possible "cheats" in the sense
  1206. > of fairly simple algorithms that make the computer play (or appear to
  1207. > play) a game well.  My game is cross between spaceward ho! and strategic
  1208. > conquest if that helps any.  Any ideas about small memory, fairly quick
  1209. > time algorithms that would help the computer would be great.  Thanks
  1210.  
  1211. Ooooh, sounds like a game I would love!
  1212.  
  1213. I think it would help a lot if you could describe the game a bit more,
  1214. but here are some off-the-cuff suggestions.
  1215.  
  1216. First is to have different behaviours associated with each unit, depend-
  1217. ing upon it's condition, locality of allied units and locality of enemy
  1218. units.  For example, a unit could have three modes: aggressive, defensive,
  1219. "dig in", retreat, etc.  Based on relative strengths and this mode, one
  1220. could determine the unit's behaviour.
  1221.  
  1222. As for attacks, have the unit do some sort of calculation on enemy units
  1223. to the unit to attack.  Note that, the algorithm used is dependent upon
  1224. what kinds of military tactics you subscribe to.  Or possibly let the
  1225. choice of algorithm be based on the kind of virtual general.
  1226.  
  1227. Finally, there is a book called "Computer Games" or somesuch that 
  1228. describes a wide variety of tactics that computer games can take vs
  1229. human beings.  Can't remember the title, but I _know_ it had sections
  1230. on military style simulations.  Another book I remember reading was 
  1231. one that did simulations based on "spheres of infulence".  This may
  1232. help the computer set up global level strategies.
  1233.  
  1234. Cheers,
  1235. Rob
  1236. ___________________________________________________________________________
  1237. Robert S. Mah  -=-  One Step Beyond  -=-  212-947-6507  -=-  rmah@panix.com
  1238.  
  1239. +++++++++++++++++++++++++++
  1240.  
  1241. >From raubvogel@gauss.aero.ufl.edu (Doctor Caligari)
  1242. Date: 28 Jun 1994 13:38:56 GMT
  1243. Organization: Cesare Somnambulisms
  1244.  
  1245. In article <rmah-280694002434@rmah.dialup.access.net>, rmah@panix.com
  1246. (Robert S. Mah) wrote:
  1247.  
  1248. > jgrass@cs.umass.edu (Joshua Grass) wrote:
  1249.  
  1250. [...]
  1251.  
  1252. > Finally, there is a book called "Computer Games" or somesuch that 
  1253. > describes a wide variety of tactics that computer games can take vs
  1254. > human beings.  Can't remember the title, but I _know_ it had sections
  1255. > on military style simulations.  Another book I remember reading was 
  1256. > one that did simulations based on "spheres of infulence".  This may
  1257. > help the computer set up global level strategies.
  1258.     Could you dig out the names of those books?
  1259.  
  1260. +++++++++++++++++++++++++++
  1261.  
  1262. >From nick@cs.stanford.edu (Nick Parlante)
  1263. Date: 28 Jun 1994 22:41:47 GMT
  1264. Organization: Stanford University
  1265.  
  1266. In article <rmah-280694002434@rmah.dialup.access.net>, rmah@panix.com
  1267. (Robert S. Mah) wrote:
  1268.  
  1269. > jgrass@cs.umass.edu (Joshua Grass) wrote:
  1270. > > I finished writing a mac game that is a pretty fun to play with two
  1271. > > people, but I would like to make it so that the computer can play as
  1272. > > well.  I'm pretty well versed in AI so I understand how hard it can
  1273. > > be for a computer to play any game, but I was curious if anyone had
  1274. > > any experience on computer strategy and possible "cheats" in the sense
  1275. > > of fairly simple algorithms that make the computer play (or appear to
  1276. > > play) a game well.  My game is cross between spaceward ho! and strategic
  1277. > > conquest if that helps any.  Any ideas about small memory, fairly quick
  1278. > > time algorithms that would help the computer would be great.  Thanks
  1279. > Ooooh, sounds like a game I would love!
  1280. > I think it would help a lot if you could describe the game a bit more,
  1281. > but here are some off-the-cuff suggestions.
  1282. > First is to have different behaviours associated with each unit, depend-
  1283. > ing upon it's condition, locality of allied units and locality of enemy
  1284. > units.  For example, a unit could have three modes: aggressive, defensive,
  1285. > "dig in", retreat, etc.  Based on relative strengths and this mode, one
  1286. > could determine the unit's behaviour.
  1287. > As for attacks, have the unit do some sort of calculation on enemy units
  1288. > to the unit to attack.  Note that, the algorithm used is dependent upon
  1289. > what kinds of military tactics you subscribe to.  Or possibly let the
  1290. > choice of algorithm be based on the kind of virtual general.
  1291. > Finally, there is a book called "Computer Games" or somesuch that 
  1292. > describes a wide variety of tactics that computer games can take vs
  1293. > human beings.  Can't remember the title, but I _know_ it had sections
  1294. > on military style simulations.  Another book I remember reading was 
  1295. > one that did simulations based on "spheres of infulence".  This may
  1296. > help the computer set up global level strategies.
  1297. > Cheers,
  1298. > Rob
  1299. > ___________________________________________________________________________
  1300. > Robert S. Mah  -=-  One Step Beyond  -=-  212-947-6507  -=-  rmah@panix.com
  1301.  
  1302. Here's a technique that's worked well for me (I used it to create 
  1303. a strategy for playing Tetris well, but it should work for any 
  1304. game)--
  1305.  
  1306. 1) Code up a BestMove() or whatever function which 
  1307. numerically evaluates the quality of a given move or position. 
  1308. Internally, the function should rely liberally on numeric 
  1309. constants such as...
  1310.  
  1311. kTankOffense // the offensive value of a "tank"
  1312. kTankOffenseDecay // how much the threat of a tank decreases 
  1313. the further you are from it
  1314.  
  1315. // A squadron of planes has a net offense which is a linear 
  1316. function of the number of planes
  1317. kPlaneY  // the y-intercept 
  1318. kPlaneSlope  // the slope
  1319.  
  1320.  
  1321. etc. etc.
  1322.  
  1323. So the point is, you structure a strategy which seems 
  1324. reasonable, but any time there's a tradeoff or something you're 
  1325. not sure about, you defer it to a float constant.
  1326.  
  1327. 2) So now the problem is reduced to finding values for the 
  1328. constants which yield a good strategy. Traditional hill-climbing 
  1329. methods to optimize the constants will have problems because 
  1330. the search space has a large number of dimensions (one for 
  1331. each constant) and whatever "rating" function you make up to 
  1332. rate the quality of a particular strategy is likely to be 
  1333. discontinuous.
  1334.  
  1335. Fortunately, Genetic Algorithms are ideal for searching this sort 
  1336. of large, discontinuous space. Here's the 10-second guide to 
  1337. genetic algorithms: create a population of maybe 500 different 
  1338. randomly generated strategies. Rate them all in some way by 
  1339. having them all play a fixed strategy, or by having them play 
  1340. each other. And finally recombine/breed the best individuals 
  1341. from the old generation to make children for a new generation. 
  1342. Just as it goes in the real world according to Darwin, the 
  1343. individuals from the old generation with the highest ratings 
  1344. should be proportionately more likely to be chosen as parents.
  1345.  
  1346. Genetic algorithms are not too hard to code up, but they can 
  1347. consume a lot of CPU time. Check out Goldberg's book Genetic 
  1348. Algorithms in Optimization and Somethingorother. Koza's 
  1349. mammoth GA book describes a more flexible but potentially 
  1350. more costly approach.
  1351.  
  1352. The quality of the strategy you get will depend very much on 
  1353. the metrics and insights which you encode in the BestMove() 
  1354. function in step (1) as well as the "rating" function you use to 
  1355. guide the optimization in step (2). I've used this technique to 
  1356. create a strategy which plays Tetris an order of magnitude 
  1357. better than anything I was able to code up on my own without 
  1358. the genetic algorithm doing the optimization.
  1359.  
  1360. Cheers,
  1361.  
  1362. Nick
  1363.  
  1364. ---------------------------
  1365.  
  1366. End of C.S.M.P. Digest
  1367. **********************
  1368.  
  1369.  
  1370. ˇ